package invest.strategy.impl;

import invest.data.DataEnum;
import invest.data.DataFactory;
import invest.pojo.ToSendRecord;
import invest.pojo.datapojo.Stock;
import invest.pojo.datapojo.StockHistory;
import invest.pojo.datapojo.StockMinuteKline;
import invest.pojo.datapojo.StockMinuteToday;
import invest.strategy.Variable;
import invest.utils.DateUtil;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import static invest.data.DataEnum.*;

@Component
public class SetOpenPrice extends AbstractStrategy {
    {
        super.cron = "0 0/10 * * * ?";
    }

    @Override
    protected void setMail() {
//        mail.setSubject("连续涨停策略");
//        mail.setContent("昨日涨停;今日竞价实际换手率大于 0.3;今日9:25涨幅大于3;(今日竞价量/昨日总成交量)〉 0.1；今日 9：25 分的涨跌幅>昨日 9：25 分的涨跌幅；股票简称不包含 ST；");
    }

    @Override
    public boolean analyzeStrategy() throws Exception {
        DataFactory dataFactory = new DataFactory();
        List<Stock> stockList = (List<Stock>) dataFactory.getData(STOCK_REALTIME);
        if (Variable.openPrice==null || Variable.openPrice.size() == 0) {
            Variable.openPrice = new HashMap<>();
        }

        for (Stock s : stockList) {
            String symble = s.getSymbol();
            DataFactory dataFactory1 = new DataFactory(symble);
            List<StockMinuteToday> stockMinuteTodays = (List<StockMinuteToday>) dataFactory1.getData(STOCK_MINUTE_TODAY_TIME);
            if (stockMinuteTodays.size() > 0) {
                Variable.openPrice.put(symble, stockMinuteTodays.get(0));
            }

        }
        return false;
    }

    public static void main(String[] args) throws IOException {
        DataFactory dataFactory = new DataFactory();
        List<Stock> stockList = (List<Stock>) dataFactory.getData(STOCK_REALTIME);
        Variable.openPrice = new HashMap<>();
        for (Stock s : stockList) {
            String symble = s.getSymbol();
            DataFactory dataFactory1 = new DataFactory(symble);
            List<StockMinuteToday> stockMinuteTodays = (List<StockMinuteToday>) dataFactory1.getData(STOCK_MINUTE_TODAY_TIME);
            if (stockMinuteTodays.size() > 0) {
                Variable.openPrice.put(symble, stockMinuteTodays.get(0));
            }

        }
        System.out.println(1);
    }
}

